
# 用于自定义异常类型

class TeslaError(Exception):
    pass

class BMWError(TeslaError):
    pass

def fx():
    raise TeslaError('特斯拉报错')
def fy():
    raise BMWError('BMW报错')
try:
    # fx()
    fy()
except TeslaError as err:
    print('特斯拉车报错！')
except BMWError as err:
    print('宝马车报错！')
except:   # 等同于 except Exception:
    pass
